package com.xypower;

import org.junit.Test;

public class swapTest {
    //交换i和j位置i上的值
   public static void swap(int arr[],int i,int j){
       int temp = 0;
       temp = arr[i];
       arr[i] = arr[j];
       arr[j] = temp;
   }
    //交换i和j位置上的值
    public static void swap2(int arr[],int i,int j){
       arr[i] = arr[i] + arr[j];
       arr[j] = arr[i] - arr[j];
       arr[i] = arr[i] - arr[j];
    }
   //交换i和j位置上的值
   public static void swap3(int arr[],int i,int j){
       arr[i] = arr[i] ^ arr[j];
       arr[j] = arr[i] ^ arr[j];
       arr[i] = arr[i] ^ arr[j];
   }
}
